import request from '@/utils/request'

// 查询主机列表
export function listHost (query) {
  return request({
    url: '/dockerinsight/host/list',
    method: 'get',
    params: query
  })
}

// 查询可用主机列表
export function getEnalbeList (query) {
  return request({
    url: '/dockerinsight/host/getEnalbeList',
    method: 'get',
    params: query
  })
}

// 查询主机详细
export function getHost (id) {
  return request({
    url: '/dockerinsight/host/' + id,
    method: 'get'
  })
}

// 新增主机
export function addHost (data) {
  return request({
    url: '/dockerinsight/host',
    method: 'post',
    data: data
  })
}

// 修改主机
export function updateHost (data) {
  return request({
    url: '/dockerinsight/host',
    method: 'put',
    data: data
  })
}

// 删除主机
export function delHost (id) {
  return request({
    url: '/dockerinsight/host/' + id,
    method: 'delete'
  })
}

// 校验主机IP是否存在
export function checkHostIpUnique (id, hostIp) {
  if (id === undefined) {
    id = ''
  }
  return request({
    url: '/dockerinsight/host/checkHostIpUnique/' + hostIp + '/' + id,
    method: 'get'
  })
}

// 导出主机
export function exportHost (query) {
  return request({
    url: '/dockerinsight/host/export',
    method: 'get',
    params: query
  })
}

// 获取初始化数据
export function getInitData (dictTypes) {
  return request({
    url: '/dockerinsight/host/getInitData/' + dictTypes,
    method: 'get'
  })
}
